package com.mca.framework.map;

import java.util.Map;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @Author: zhoupeng
 * @createTime: 2025年07月23日 21:54:27
 * @version: 1.0
 * @Description:
 * @copyright:
 */
public class DemoConcurrentHashMap {

    public static void main(String[] args) throws InterruptedException {
        //定义ConcurrentHashMap
        Map map=new ConcurrentHashMap<>();
        for (int i = 0; i <10 ; i++) {
            new Thread(new Runnable() {
                @Override
                public void run() {
                  //多线程下的put可以使用，由于它是线程安全的
                  map.put(UUID.randomUUID().toString(),"1");
                }
            }).start();
        }
        Thread.sleep(3000);
        System.out.println(map);
    }
}
